-
Notifications
You must be signed in to change notification settings - Fork 14
CLOUDP-271988: IPA-102: Validate paths follow expected format #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tools/spectral/ipa/rulesets/functions/eachPathAlternatesBetweenResourceNameAndPathParam.js
Outdated
Show resolved
Hide resolved
tools/spectral/ipa/rulesets/functions/eachPathAlternatesBetweenResourceNameAndPathParam.js
Show resolved
Hide resolved
description: "APIs must provide a get method for resources. http://go/ipa/104" | ||
message: "{{error}} http://go/ipa/117" | ||
description: 'APIs must provide a get method for resources. http://go/ipa/104' | ||
message: '{{error}} http://go/ipa/104' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
tools/spectral/ipa/__tests__/eachPathAlternatesBetweenResourceNameAndPathParam.test.js
Outdated
Show resolved
Hide resolved
const validatePathStructure = (elements) => { | ||
return elements.every((element, index) => { | ||
const isEvenIndex = index % 2 === 0; | ||
return isEvenIndex ? !isPathParam(element) : isPathParam(element); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return isEvenIndex ? !isPathParam(element) : isPathParam(element); | |
return isEvenIndex && !isPathParam(element); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the index is odd, it will return false this way. Am I missing anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Proposed changes
Jira ticket: CLOUDP-271988
Implements a rule under IPA-102, which checks if the paths are alternating between resource name and path param.
Assumptions:
api/atlas/v2
or/api/atlas/v2/unauth
prefixesapi/atlas/v2
or/api/atlas/v2/unauth
by themselves are valid pathspathParam
is in the format of{[a-z][a-zA-Z0-9]*}
or{[a-z][a-zA-Z0-9]*}:[a-z][a-zA-Z0-9]*
if custom methods attachedresourceName
and alternates withpathParam
pathParam
orresourceName
for the cases such ascamelCase
orplurality
Checklist
Changes to Spectral
Further comments